package pattern.singleton.内部类;

import java.io.*;

public class Client {
    public static void main(String[] args) throws Exception {
        writeObject2File();
        readObjectFormFile();
        readObjectFormFile();
        
    }
    
    public static void readObjectFormFile() throws Exception {
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("D:\\workfile\\学习\\a.txt"));
        Singleton singleton = (Singleton) ois.readObject();
        System.out.println(singleton);
        ois.close();
    }
    
    public static void writeObject2File() throws Exception{
        Singleton instance = Singleton.getInstance();
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("D:\\workfile\\学习\\a.txt"));
        oos.writeObject(instance);
        oos.close();
    }
}
